package com.heima.feign.client;

import com.heima.feign.config.DefaultFeignConfiguration;
import com.heima.feign.config.TaskScheduleFeignClientFallbackFactory;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.schedule.dto.TaskDto;
import com.heima.model.schedule.entity.TaskInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "leadnews-schedule",configuration = DefaultFeignConfiguration.class,fallbackFactory = TaskScheduleFeignClientFallbackFactory.class)
public interface TaskScheduleFeignClient {

    @PostMapping(path = "/api/v1/task/add")
    ResponseResult<Long> addTask(@RequestBody TaskDto task);

    @DeleteMapping(path = "/api/v1/task/{taskId}")
    ResponseResult cancel(@PathVariable("taskId") Long taskId);

    @GetMapping(path = "/api/v1/task/poll/{taskType}/{priority}")
    ResponseResult<TaskInfo> poll(@PathVariable("taskType") Integer taskType, @PathVariable("priority") Integer priority);


}
